//
//  MainViewController.swift
//  DLCjingling
//
//  Created by 顿理超 on 16/4/10.
//  Copyright © 2016年 顿理超. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    @IBOutlet weak var mainTabBar: MainTabBar!
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        addChildViewControllers()
        mainTabBar.composedButton.addTarget(self, action: "clinkCompose", forControlEvents: UIControlEvents.TouchUpInside)
        func clinkCompose(){
        //print("\(__FUNCTION__)")
        }
    }
    /// 添加所有的字子视图控制器
    
    private func addChildViewControllers() {
        
        tabBar.tintColor = UIColor.orangeColor()
        
        addChildViewController("Home", "首页", "tabbar_home")
        addChildViewController("Message", "消息", "tabbar_message_center")
        addChildViewController("Discover", "发现", "tabbar_discover")
        addChildViewController("Profile", "我", "tabbar_profile")
        
    }
    
    private func addChildViewController(sbName: String,_ title:String,_ imageName:String) {
        
        let sb = UIStoryboard(name: sbName, bundle: nil)
        let nav = sb.instantiateInitialViewController() as! UINavigationController
        
        nav.title = title
        nav.topViewController?.title = title
        nav.tabBarItem.image = UIImage(named: imageName)
        nav.tabBarItem.selectedImage = UIImage(named: imageName + "_highlighted")
        
        addChildViewController(nav)
    }
}
